using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;

namespace Eve.API
{
    /// <summary>
    /// Represents information about a group of skills.
    /// </summary>
    /// <remarks>
    /// <para>
    /// The <b>SkillGroup</b> class represents information about a group of skills within the Eve universe.  
    /// These groups make up the basis of the skill tree within eve.
    /// </para>
    /// </remarks>
    [Serializable]
    public class SkillGroup
    {
        private NameId group = new NameId();
        private List<Skill> skills = new List<Skill>();

        /// <summary>
        /// Gets the name and identifier of the skill group.
        /// </summary>
        /// <value>
        /// The name and Eve internal identifier of the skill group.
        /// </value>
        /// <remarks>
        /// The value of the <b>Id</b> property of the <see cref="Eve.API.NameId">NameId</see> structure represents an
        /// Eve internal type identifier and can be used to get detailed information about the skill group using the
        /// <b>Eve.Data</b> class library.
        /// </remarks>
        public NameId Group
        {
            get { return group; }
        }
        /// <summary>
        /// Gets a list of all skills contained in the group.
        /// </summary>
        /// <value>
        /// A list of all skills contained in the group.
        /// </value>
        public List<Skill> Skills
        {
            get { return skills; }
        }

        internal SkillGroup(XmlElement sg)
        {
            group.Name = sg.Attributes["groupName"].Value;
            group.Id = int.Parse(sg.Attributes["groupID"].Value);
            foreach (XmlElement row in sg["rowset"].ChildNodes)
                if (!row.IsEmpty) skills.Add(new Skill(row));
        }
    }
}
